home *** CD-ROM | disk | FTP | other *** search
/ PC Player 2004 May / pc player 2004-05.iso / Demos / FarCry / Data1.cab / _0D3B12BB1280432ABDAF0E321063A4DE < prev    next >
Encoding:
Text File  |  2004-01-06  |  6.7 KB  |  181 lines

  1. --------------------------------------------------
  2. --   Created By: Petar
  3. --   Description: Rear Idle Behaviour
  4. --------------------------
  5.  
  6.  
  7. AIBehaviour.MutantRearIdle = {
  8.     Name = "MutantRearIdle",
  9.  
  10.     ---------------------------------------------
  11.     OnActivate = function( self, entity )
  12.         -- called when enemy receives an activate event (from a trigger, for example)
  13.     end,
  14.     ---------------------------------------------
  15.     OnNoTarget = function( self, entity )
  16.         -- called when the enemy stops having an attention target
  17.     end,
  18.     ---------------------------------------------        
  19.     OnPlayerSeen = function( self, entity, fDistance )
  20.         -- called when the enemy sees a living player
  21.         if (fDistance < 10) then
  22.             entity:SelectPipe(0,"m_c_rush_target");
  23.         else    
  24.             -- ranged attacks
  25.  
  26.             if (AI:GetGroupCount(entity.id)>1) then 
  27.                 entity:SelectPipe(0,"mutant_monkey_attack");
  28.             else
  29.                 local rnd = random(1,10);
  30.                 if (rnd<5) then
  31.                     entity:SelectPipe(0,"mutant_refract_attack");                
  32.                 else
  33.                     entity:SelectPipe(0,"mutant_refract_sneak");                
  34.                 end
  35.             end
  36.         end
  37.     end,
  38.     ---------------------------------------------
  39.     OnEnemyMemory = function( self, entity )
  40.     end,
  41.     ---------------------------------------------
  42.     OnInterestingSoundHeard = function( self, entity )
  43.         -- called when the enemy hears an interesting sound
  44.          entity:SelectPipe(0,"rear_attentive"); -- in PipeManagerShared.lua
  45.          entity:InsertSubpipe(0,"DropBeaconAt"); -- in PipeManagerShared.lua
  46.     end,
  47.     ---------------------------------------------
  48.     OnThreateningSoundHeard = function( self, entity )
  49.         -- called when the enemy hears a scary sound
  50.         entity:SelectPipe(0,"rear_disturbed"); -- in PipeManagerShared.lua
  51.         entity:InsertSubpipe(0,"DropBeaconAt"); -- in PipeManagerShared.lua
  52.     end,
  53.     ---------------------------------------------
  54.     OnReload = function( self, entity )
  55.         -- called when the enemy goes into automatic reload after its clip is empty
  56.     end,
  57.     --------------------------------------------------
  58.     OnNoHidingPlace = function( self, entity, sender )
  59.         -- called when no hiding place can be found with the specified parameters
  60.     end,
  61.     ---------------------------------------------
  62.     OnBulletRain = function ( self, entity, sender)    
  63.         
  64.         -- DO NOT TOUCH THIS READIBILITY SIGNAL    ------------------------
  65.         AI:Signal(SIGNALID_READIBILITY, 2, "GETTING_SHOT_AT",entity.id);
  66.         ----------------------------------------------------------------
  67.  
  68.         AI:Signal(SIGNALFILTER_GROUPONLY, 1, "INCOMING_FIRE",entity.id);
  69.  
  70.         -- Make this guy alerted
  71.         entity:MakeAlerted();
  72.  
  73.         entity:SelectPipe(0,"rear_crouchlook");
  74.     end,
  75.     ---------------------------------------------
  76.     OnReceivingDamage = function ( self, entity, sender)
  77.  
  78.         -- DO NOT TOUCH THIS READIBILITY SIGNAL    ------------------------
  79.         AI:Signal(SIGNALID_READIBILITY, 1, "GETTING_SHOT_AT",entity.id);
  80.         ----------------------------------------------------------------
  81.         
  82.         AI:Signal(SIGNALFILTER_GROUPONLY, 1, "INCOMING_FIRE",entity.id);
  83.         
  84.         -- Make this guy alerted
  85.         entity:MakeAlerted();
  86.         
  87.         -- the character will go into UnderFire behaviour after this function
  88.         entity:SelectPipe(0,"rear_crouchlook");
  89.     end,
  90.     --------------------------------------------------
  91.     OnGrenadeSeen = function( self, entity, fDistance )
  92.         -- called when the enemy sees a grenade
  93.         --System:LogToConsole("+++++++++++++++++++++++++++OnGrenadeSeen");
  94.         entity:InsertSubpipe(0,"grenade_run_away");
  95.     end,
  96.     --------------------------------------------------
  97.     -- CUSTOM SIGNALS
  98.     --------------------------------------------------
  99.     DEATH_CONFIRMED = function (self, entity, sender)
  100.         --System:LogToConsole(entity:GetName().." recieved DEATH_CONFIRMED command in CoverAlert");
  101.         entity:SelectPipe(0,"ChooseManner");
  102.     end,
  103.     --------------------------------------------------
  104.     TRY_TO_LOCATE_SOURCE = function (self, entity, sender)
  105.         -- called from "randomhide"
  106.         entity:SelectPipe(0,"rear_lookaround_threatened");
  107.     end,
  108.     ---------------------------------------------
  109.     ChooseManner = function (self, entity, sender)
  110.         --System:LogToConsole("### ChooseManner ###");
  111.         local XRandom = random(1,3);
  112.         if (XRandom == 1) then
  113.             entity:InsertSubpipe(0,"LookForThreat");            
  114.         elseif (XRandom == 2) then
  115.             entity:InsertSubpipe(0,"RandomSearch");            
  116.         elseif (XRandom == 3) then
  117.             entity:InsertSubpipe(0,"ApproachDeadBeacon");
  118.         end
  119.     end,
  120.     ---------------------------------------------
  121.     OnGroupMemberDied = function( self, entity, sender)
  122.         -- called when a member of the group dies
  123.         --System:LogToConsole(entity:GetName().." recieved OnGroupMemberDied signal in RearIdle");
  124.  
  125.         entity:MakeAlerted();
  126.         
  127.         if (sender.Properties.groupid == entity.Properties.groupid) then
  128.              if (entity ~= sender) then
  129.                  entity:SelectPipe(0,"TeamMemberDiedLook");
  130.              end
  131.         else
  132.              entity:SelectPipe(0,"randomhide");
  133.         end
  134.     end,
  135.     --------------------------------------------------
  136.     OnGroupMemberDiedNearest = function ( self, entity, sender)
  137.         --System:LogToConsole(entity:GetName().." recieved OnGroupMemberDiedNearest signal in CoverIdle");
  138.  
  139.         entity:MakeAlerted();
  140.  
  141.         -- DO NOT TOUCH THIS READIBILITY SIGNAL    ---------------------------
  142.         AI:Signal(SIGNALID_READIBILITY, 1, "FRIEND_DEATH",entity.id);
  143.         -------------------------------------------------------------------
  144.         
  145.         -- bounce the dead friend notification to the group (you are going to investigate it)
  146.         AI:Signal(SIGNALFILTER_SPECIESONLY, 1, "OnGroupMemberDied",entity.id);
  147.  
  148.         -- investigate corpse
  149.         entity:SelectPipe(0,"RecogCorpse",sender.id);
  150.     end,
  151.     --------------------------------------------------
  152.     ----------------- GROUP SIGNALS ------------------
  153.     --------------------------------------------------
  154.     HEADS_UP_GUYS = function (self, entity, sender)
  155.         if (entity ~= sender) then
  156.             entity:MakeAlerted();
  157.             entity:SelectPipe(0,"rear_headup");
  158.         end
  159.     end,
  160.     ---------------------------------------------
  161.     INCOMING_FIRE = function (self, entity, sender)
  162.         if (entity ~= sender) then
  163.             entity:SelectPipe(0,"randomhide");
  164.             entity:InsertSubpipe(0,"look_in_direction_of",sender.id);
  165.         end
  166.     end,
  167.     ---------------------------------------------
  168.     OnCoverRequested = function ( self, entity, sender)
  169.         -- called when cover is requested
  170.     end,
  171.     ------------------------------------------------------------------------
  172.     ------------------------------ Animation -------------------------------
  173.     PlayGetDownAnim = function (self, entity, sender)
  174.         entity:StartAnimation(0,"pgetdown",0);
  175.     end,
  176.     ------------------------------------------------------------------------
  177.     PlayGetUpAnim = function (self, entity, sender)
  178.         entity:StartAnimation(0,"pgetup",0);
  179.     end,
  180.     ------------------------------------------------------------------------
  181. }